﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JWXH.XH.pages.listview.viewmodel;
using MvvmHelpers;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace JWXH.XH.pages.listview
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class ListViewGroup : ContentPage
    {
        public ListViewTest1Model ViewModel { get; set; } = new ListViewTest1Model();
        public ListViewGroup()
        {
            InitializeComponent();

            BindingContext = ViewModel;
            #region 初始化数据
            ViewModel.Title = "grouplist";
            ViewModel.ListItems = new List<FlyWall>()
            {
                new FlyWall()
                {
                    Name = "shadowsocks",
                    Desc = "first fly wall tool",
                    Img = "http://jwell-xh.oss-cn-shenzhen.aliyuncs.com/20180226093621_ac3530503ab64bc0a30546b7b98af417_.jpg?x-oss-process=image/resize,h_224,w_280",
                    Type = "ss"
                },new FlyWall()
                {
                    Name = "shadowsocksR",
                    Desc = "more speed fly wall tools",
                    Img = "http://www.52hhx.com/imgs/header_21ebbfd7.png",
                    Type = "ss"
                },new FlyWall()
                {
                    Name = "v2ray",
                    Desc = "more safe and speed",
                    Img = "http://jwell-xh.oss-cn-shenzhen.aliyuncs.com/20180223135656_f70a80b8e4694dc889b7ec0a383e788d_.jpg?x-oss-process=image/resize,h_224,w_280",
                    Type = "vmss"
                }, new FlyWall()
                {
                    Name = "shadowsocks",
                    Desc = "first fly wall tool",
                    Img = "http://jwell-xh.oss-cn-shenzhen.aliyuncs.com/20180226093621_ac3530503ab64bc0a30546b7b98af417_.jpg?x-oss-process=image/resize,h_224,w_280",
                    Type = "ss"
                },new FlyWall()
                {
                    Name = "shadowsocksR",
                    Desc = "more speed fly wall tools",
                    Img = "http://www.52hhx.com/imgs/header_21ebbfd7.png",
                    Type = "ss"
                },new FlyWall()
                {
                    Name = "v2ray",
                    Desc = "more safe and speed",
                    Img = "http://jwell-xh.oss-cn-shenzhen.aliyuncs.com/20180223135656_f70a80b8e4694dc889b7ec0a383e788d_.jpg?x-oss-process=image/resize,h_224,w_280",
                    Type = "vmss"
                }, new FlyWall()
                {
                    Name = "shadowsocks",
                    Desc = "first fly wall tool",
                    Img = "http://jwell-xh.oss-cn-shenzhen.aliyuncs.com/20180226093621_ac3530503ab64bc0a30546b7b98af417_.jpg?x-oss-process=image/resize,h_224,w_280",
                    Type = "ss"
                },new FlyWall()
                {
                    Name = "shadowsocksR",
                    Desc = "more speed fly wall tools",
                    Img = "http://www.52hhx.com/imgs/header_21ebbfd7.png",
                    Type = "ss"
                },new FlyWall()
                {
                    Name = "v2ray",
                    Desc = "more safe and speed",
                    Img = "http://jwell-xh.oss-cn-shenzhen.aliyuncs.com/20180223135656_f70a80b8e4694dc889b7ec0a383e788d_.jpg?x-oss-process=image/resize,h_224,w_280",
                    Type = "vmss"
                }
            };
            #endregion

            listViwGroup.ItemsSource = from u in ViewModel.ListItems
                                       orderby u.Name
                                       group u by u.Type into uGroup
                                       select new Grouping<String, FlyWall>(uGroup.Key, uGroup);
        }
    }
}